Imports System.Data.OleDb
Imports System.Data
Imports System.Data.SqlClient
Imports System.Data.SqlServerCe
Imports System.Data.OracleClient
Imports MySql.Data.MySqlClient
Imports DTO
Public Class AbstractDao
    Inherits DataTable
    Public Enum Class_KieuDL
        Access = 0
        sql = 1
        SqlCe = 2
        Xml = 3
        Oracle = 4
        sqlExpress = 5
        MySql = 6
    End Enum
    Public Ketnoi As KetNoiDto
    Public ConnectionThanhcong As Boolean = False
#Region "Khai báo cục bộ"
    Public WithEvents mBo_doc_ghi_access As OleDbDataAdapter
    Public WithEvents mBo_doc_ghi_sql As SqlDataAdapter
    Public WithEvents mBo_doc_ghi_sqlExpress As SqlDataAdapter
    Public WithEvents mBo_doc_ghi_sqlce As SqlCeDataAdapter
    Public WithEvents mBo_doc_ghi_Oracle As OracleDataAdapter
    Public WithEvents mBo_doc_ghi_MySql As MySqlDataAdapter
    Public batloi As Boolean = False
    Private mChuoi_SQL As String
    Private mTen_bang As String
    Private Shared WithEvents mKet_noi_Access As OleDbConnection
    Private Shared WithEvents mKet_noi_Sql As SqlConnection
    Private Shared WithEvents mKet_noi_sqlExpress As SqlConnection
    Private Shared WithEvents mKet_noi_SqlCe As SqlCeConnection
    Private Shared WithEvents mKet_noi_Oracle As OracleConnection
    Private Shared WithEvents mKet_noi_MySql As MySqlConnection
#End Region
#Region "Khai báo thuộc tính"
    Public Property Chuoi_SQL() As String
        Get
            Return mChuoi_SQL
        End Get
        Set(ByVal Value As String)
            mChuoi_SQL = Value
        End Set
    End Property
    Public Shared Property Ket_noi_MySql() As MySqlConnection
        Get
            Return mKet_noi_MySql
        End Get
        Set(ByVal Value As MySqlConnection)
            mKet_noi_MySql = Value
        End Set
    End Property
    Public Property Ten_bang() As String
        Get
            Return mTen_bang
        End Get
        Set(ByVal Value As String)
            mTen_bang = Value
        End Set
    End Property
    Public Shared Property Ket_noi_Access() As OleDbConnection
        Get
            Return mKet_noi_Access
        End Get
        Set(ByVal Value As OleDbConnection)
            mKet_noi_Access = Value
        End Set
    End Property
    Public Shared Property Ket_noi_Sql() As SqlConnection
        Get
            Return mKet_noi_Sql
        End Get
        Set(ByVal Value As SqlConnection)
            mKet_noi_Sql = Value
        End Set
    End Property
    Public Shared Property Ket_noi_sqlExpress() As SqlConnection
        Get
            Return mKet_noi_sqlExpress
        End Get
        Set(ByVal Value As SqlConnection)
            mKet_noi_sqlExpress = Value
        End Set
    End Property
    Public Shared Property Ket_noi_SqlCe() As SqlCeConnection
        Get
            Return mKet_noi_SqlCe
        End Get
        Set(ByVal Value As SqlCeConnection)
            mKet_noi_SqlCe = Value
        End Set
    End Property
    Public Shared Property Ket_noi_Oracle() As OracleConnection
        Get
            Return mKet_noi_Oracle
        End Get
        Set(ByVal Value As OracleConnection)
            mKet_noi_Oracle = Value
        End Set
    End Property
    Public ReadOnly Property So_dong() As Long
        Get
            Return Me.DefaultView.Count
        End Get
    End Property
#End Region
#Region "Khai báo phương thức khởi tạo"
    Private Sub connectionString(Optional ByVal Kiemtra As Boolean = False)
        Select Case ketnoi.MSsql
            Case Class_KieuDL.Access
                If mKet_noi_Access Is Nothing Or Kiemtra Then
                    mKet_noi_Access = New OleDbConnection
                    mKet_noi_Access.ConnectionString = ketnoi.ChuoiKetNoi
                End If
            Case Class_KieuDL.Sql
                If mKet_noi_Sql Is Nothing Or Kiemtra Then
                    mKet_noi_Sql = New SqlConnection
                    mKet_noi_Sql.ConnectionString = ketnoi.ChuoiKetNoi
                End If
            Case Class_KieuDL.sqlExpress
                If mKet_noi_sqlExpress Is Nothing Or Kiemtra Then
                    mKet_noi_sqlExpress = New SqlConnection
                    mKet_noi_sqlExpress.ConnectionString = ketnoi.ChuoiKetNoi
                End If
            Case Class_KieuDL.SqlCe
                If mKet_noi_SqlCe Is Nothing Or Kiemtra Then
                    mKet_noi_SqlCe = New SqlCeConnection
                    mKet_noi_SqlCe.ConnectionString = ketnoi.ChuoiKetNoi
                End If
            Case Class_KieuDL.Oracle
                If mKet_noi_Oracle Is Nothing Or Kiemtra Then
                    mKet_noi_Oracle = New OracleConnection
                    mKet_noi_Oracle.ConnectionString = ketnoi.ChuoiKetNoi
                End If
            Case Class_KieuDL.MySql
                If mKet_noi_MySql Is Nothing Or Kiemtra Then
                    mKet_noi_MySql = New MySqlConnection
                    mKet_noi_MySql.ConnectionString = ketnoi.ChuoiKetNoi
                End If
        End Select
    End Sub
    Public Sub New(ByVal Connection As KetNoiDto, Optional ByVal Kiemtra As Boolean = False)
        MyBase.New()
        ketnoi = Connection
        connectionString(Kiemtra)
    End Sub
    Public Sub New(ByVal pTen_bang As String, ByVal Connection As KetNoiDto)
        MyBase.New(pTen_bang)
        mTen_bang = pTen_bang
        Ketnoi = Connection
        connectionString()
        Doc_bang()
    End Sub
    Public Sub New(ByVal pTen_bang As String, ByVal pChuoi_SQL As String, ByVal Connection As KetNoiDto)
        MyBase.New()
        mTen_bang = pTen_bang
        mChuoi_SQL = pChuoi_SQL
        Ketnoi = Connection
        connectionString()
        Doc_bang()
    End Sub
#End Region
#Region "Khai báo phương thức xử lý - Nhóm cung cấp thông tin"
    Public Function Moketnoi() As Boolean
        Select Case ketnoi.MsSql
            Case Class_KieuDL.Access
                If mKet_noi_Access.State = ConnectionState.Closed Then mKet_noi_Access.Open()
            Case Class_KieuDL.Sql
                If mKet_noi_Sql.State = ConnectionState.Closed Then mKet_noi_Sql.Open()
            Case Class_KieuDL.sqlExpress
                If mKet_noi_sqlExpress.State = ConnectionState.Closed Then mKet_noi_sqlExpress.Open()
            Case Class_KieuDL.SqlCe
                If mKet_noi_SqlCe.State = ConnectionState.Closed Then mKet_noi_SqlCe.Open()
            Case Class_KieuDL.Oracle
                If mKet_noi_Oracle.State = ConnectionState.Closed Then mKet_noi_Oracle.Open()
            Case Class_KieuDL.MySql
                If mKet_noi_MySql.State = ConnectionState.Closed Then mKet_noi_MySql.Open()
        End Select
    End Function
    Public Function Ngatketnoi() As Boolean
        Select Case ketnoi.MsSql
            Case Class_KieuDL.Access
                If mKet_noi_Access.State = ConnectionState.Open Then mKet_noi_Access.Close()
            Case Class_KieuDL.Sql
                If mKet_noi_Sql.State = ConnectionState.Open Then mKet_noi_Sql.Close()
            Case Class_KieuDL.sqlExpress
                If mKet_noi_sqlExpress.State = ConnectionState.Open Then mKet_noi_sqlExpress.Close()
            Case Class_KieuDL.SqlCe
                If mKet_noi_SqlCe.State = ConnectionState.Open Then mKet_noi_SqlCe.Close()
            Case Class_KieuDL.Oracle
                If mKet_noi_Oracle.State = ConnectionState.Open Then mKet_noi_Oracle.Close()
            Case Class_KieuDL.MySql
                If mKet_noi_MySql.State = ConnectionState.Open Then mKet_noi_MySql.Close()
        End Select
    End Function
    Public Sub CopyBangALL(ByVal sqlcon_nguon As SqlConnection)
        Dim data As DataTable = DanhSachBang()
        If sqlcon_nguon.State = ConnectionState.Closed Then sqlcon_nguon.Open()
        For i As Integer = 0 To data.Rows.Count - 1
            Dim table As New DataTable
            Dim SQL As String = "Select * from" & Data.Rows(i)(0)
            Dim Cmd As New SqlDataAdapter(SQL, sqlcon_nguon)
            Cmd.Fill(table)
            CopyBang(table, Data.Rows(i)(0))
        Next
        If sqlcon_nguon.State = ConnectionState.Open Then sqlcon_nguon.Close()
    End Sub
    Public Function DanhSachBang(ByVal sqlcon As SqlConnection) As DataTable
        Dim MySQL As String = "Select Name from SysObjects Where Xtype ='U' order by Name"
        Dim table As New DataTable
        If sqlcon.State = ConnectionState.Closed Then sqlcon.Open()
        Dim Cmd As New SqlDataAdapter(MySQL, sqlcon)
        Cmd.Fill(table)
        If sqlcon.State = ConnectionState.Open Then sqlcon.Close()
        Return table
    End Function
    Public Function DanhSachBang() As DataTable
        Dim MySQL As String = "Select Name from SysObjects Where Xtype ='U' order by Name"
        Dim table As New DataTable
        If mKet_noi_Sql.State = ConnectionState.Closed Then mKet_noi_Sql.Open()
        Dim Cmd As New SqlDataAdapter(MySQL, mKet_noi_sql)
        Cmd.Fill(table)
        If mKet_noi_Sql.State = ConnectionState.Open Then mKet_noi_Sql.Close()
        Return table
    End Function
    Public Sub Xoalogfile_SqlServer()
        Dim MySQL As String = "  Backup log " & Ketnoi._DataBase & " With truncate_only DBCC SHRINKDATABASE (" & Ketnoi._DataBase & ")"
        If mKet_noi_Sql.State = ConnectionState.Closed Then mKet_noi_Sql.Open()
        Dim Cmd As New SqlCommand(MySQL, mKet_noi_Sql)
        Cmd.ExecuteNonQuery()
        If mKet_noi_Sql.State = ConnectionState.Open Then mKet_noi_Sql.Close()
    End Sub
    Public Sub CopyBang(ByVal BangNguon As DataTable, ByVal Tenbang As String)
        Dim Lenhxoa As String = " delete from  " & Tenbang
        If mKet_noi_Sql.State = ConnectionState.Closed Then mKet_noi_Sql.Open()
        Dim cmd1 As New SqlCommand(Lenhxoa, mKet_noi_sql)
        cmd1.ExecuteNonQuery()
        Dim copy As New System.Data.SqlClient.SqlBulkCopy(mKet_noi_sql)
        copy.DestinationTableName = Tenbang
        For j As Integer = 0 To BangNguon.Columns.Count - 1
            copy.ColumnMappings.Add(BangNguon.Columns(j).ColumnName, BangNguon.Columns(j).ColumnName)
        Next
        copy.WriteToServer(BangNguon)
        copy.Close()
        If mKet_noi_Sql.State = ConnectionState.Open Then mKet_noi_Sql.Close()
    End Sub
    Public Sub Doc_bang()
        ConnectionThanhcong = True
        If mChuoi_SQL = "" Then mChuoi_SQL = "SELECT * FROM " & mTen_bang
        Moketnoi()
        Select Case ketnoi.MSsql
            Case Class_KieuDL.Access
                Try
                    mBo_doc_ghi_access = New OleDbDataAdapter(mChuoi_SQL, mKet_noi_Access)
                    mBo_doc_ghi_Access.Fill(Me)
                Catch ex As OleDbException
                    ConnectionThanhcong = False
                    If BatLoi = True Then MsgBox("Khong thuc hien dc!" & vbNewLine & ex.Message, vbCritical, "Loi thuc hien")
                    Exit Sub
                End Try
            Case Class_KieuDL.Sql
                Try
                    mBo_doc_ghi_Sql = New SqlDataAdapter(mChuoi_SQL, mKet_noi_sql)
                    mBo_doc_ghi_sql.Fill(Me)
                Catch ex As SqlException
                    ConnectionThanhcong = False
                    If BatLoi = True Then MsgBox("Khong thuc hien dc!" & vbNewLine & ex.Message, vbCritical, "Loi thuc hien")
                    Exit Sub
                End Try
            Case Class_KieuDL.sqlExpress
                Try
                    mBo_doc_ghi_sqlExpress = New SqlDataAdapter(mChuoi_SQL, mKet_noi_sqlExpress)
                    mBo_doc_ghi_sqlExpress.Fill(Me)
                Catch ex As SqlException
                    ConnectionThanhcong = False
                    If BatLoi = True Then MsgBox("Khong thuc hien dc!" & vbNewLine & ex.Message, vbCritical, "Loi thuc hien")
                    Exit Sub
                End Try
            Case Class_KieuDL.SqlCe
                Try
                    mBo_doc_ghi_SqlCe = New SqlCeDataAdapter(mChuoi_SQL, mKet_noi_sqlCe)
                    mBo_doc_ghi_sqlCe.Fill(Me)
                Catch ex As sqlCeException
                    ConnectionThanhcong = False
                    If BatLoi = True Then MsgBox("Khong thuc hien dc!" & vbNewLine & ex.Message, vbCritical, "Loi thuc hien")
                    Exit Sub
                End Try
            Case Class_KieuDL.Oracle
                Try
                    mBo_doc_ghi_Oracle = New OracleDataAdapter(mChuoi_SQL, mKet_noi_Oracle)
                    mBo_doc_ghi_Oracle.Fill(Me)
                Catch ex As OracleException
                    ConnectionThanhcong = False
                    If BatLoi = True Then MsgBox("Khong thuc hien dc!" & vbNewLine & ex.Message, vbCritical, "Loi thuc hien")
                    Exit Sub
                End Try
            Case Class_KieuDL.MySql
                Try
                    mBo_doc_ghi_MySql = New MySqlDataAdapter(mChuoi_SQL, mKet_noi_MySql)
                    mBo_doc_ghi_MySql.Fill(Me)
                Catch ex As MySqlException
                    ConnectionThanhcong = False
                    If BatLoi = True Then MsgBox("Khong thuc hien dc!" & vbNewLine & ex.Message, vbCritical, "Loi thuc hien")
                    Exit Sub
                End Try
        End Select
        Ngatketnoi()
    End Sub
    Public Sub Doc_bang_Dk_ngay(ByVal ngay As Date, Optional ByVal denngay As Date = #1/1/1900#)
        ConnectionThanhcong = True
        If mChuoi_SQL = "" Then mChuoi_SQL = "SELECT * FROM " & mTen_bang
        Moketnoi()
        Select Case ketnoi.MsSql
            Case Class_KieuDL.Access
                Try
                    Dim cmd As New OleDbCommand(mChuoi_SQL, mKet_noi_Access)
                    cmd.Parameters.Add("@Ngay", OleDbType.Date).Value = ngay
                    If denngay <> #1/1/1900# Then cmd.Parameters.Add("@denNgay", OleDbType.Date).Value = denngay
                    mBo_doc_ghi_access = New OleDbDataAdapter(cmd)
                    mBo_doc_ghi_access.Fill(Me)
                Catch ex As OleDbException
                    ConnectionThanhcong = False
                    If batloi = True Then MsgBox("Không thực hiện dc!" & vbNewLine & ex.Message, vbCritical, "Lổi thực hiện")
                    Exit Sub
                End Try
            Case Class_KieuDL.Sql
                Try
                    Dim cmd As New SqlCommand(mChuoi_SQL, mKet_noi_Sql)
                    cmd.Parameters.Add("@Ngay", SqlDbType.DateTime).Value = ngay
                    If denngay <> #1/1/1900# Then cmd.Parameters.Add("@denNgay", SqlDbType.Date).Value = denngay
                    mBo_doc_ghi_sql = New SqlDataAdapter(cmd)
                    mBo_doc_ghi_sql.Fill(Me)
                Catch ex As SqlException
                    ConnectionThanhcong = False
                    If batloi = True Then MsgBox("Không thực hiện dc!" & vbNewLine & ex.Message, vbCritical, "Lổi thực hiện")
                    Exit Sub
                End Try
            Case Class_KieuDL.sqlExpress
                Try
                    Dim cmd As New SqlCommand(mChuoi_SQL, mKet_noi_Sql)
                    cmd.Parameters.Add("@Ngay", SqlDbType.DateTime).Value = ngay
                    If denngay <> #1/1/1900# Then cmd.Parameters.Add("@denNgay", SqlDbType.Date).Value = denngay
                    mBo_doc_ghi_sqlExpress = New SqlDataAdapter(cmd)
                    mBo_doc_ghi_sqlExpress.Fill(Me)
                Catch ex As SqlException
                    ConnectionThanhcong = False
                    If batloi = True Then MsgBox("Không thực hiện dc!" & vbNewLine & ex.Message, vbCritical, "Lổi thực hiện")
                    Exit Sub
                End Try
            Case Class_KieuDL.SqlCe
                Try
                    Dim cmd As New SqlCeCommand(mChuoi_SQL, mKet_noi_SqlCe)
                    cmd.Parameters.Add("@Ngay", SqlDbType.DateTime).Value = ngay
                    If denngay <> #1/1/1900# Then cmd.Parameters.Add("@denNgay", SqlDbType.Date).Value = denngay
                    mBo_doc_ghi_sqlce = New SqlCeDataAdapter(mChuoi_SQL, mKet_noi_SqlCe)
                    mBo_doc_ghi_sqlce.Fill(Me)
                Catch ex As SqlCeException
                    ConnectionThanhcong = False
                    If batloi = True Then MsgBox("Không thực hiện dc!" & vbNewLine & ex.Message, vbCritical, "Lổi thực hiện")
                    Exit Sub
                End Try
            Case Class_KieuDL.Oracle
                Try
                    Dim cmd As New OracleCommand(mChuoi_SQL, mKet_noi_Oracle)
                    cmd.Parameters.Add("@Ngay", OracleType.DateTime).Value = ngay
                    If denngay <> #1/1/1900# Then cmd.Parameters.Add("@denNgay", OracleType.DateTime).Value = denngay
                    mBo_doc_ghi_Oracle = New OracleDataAdapter(cmd)
                    mBo_doc_ghi_Oracle.Fill(Me)
                Catch ex As OracleException
                    ConnectionThanhcong = False
                    If batloi = True Then MsgBox("Không thực hiện dc!" & vbNewLine & ex.Message, vbCritical, "Lổi thực hiện")
                    Exit Sub
                End Try
            Case Class_KieuDL.MySql
                Try
                    Dim cmd As New MySqlCommand(mChuoi_SQL, mKet_noi_MySql)
                    cmd.Parameters.Add("@Ngay", MySqlDbType.DateTime).Value = ngay
                    If denngay <> #1/1/1900# Then cmd.Parameters.Add("@denNgay", MySqlDbType.Date).Value = denngay
                    mBo_doc_ghi_MySql = New MySqlDataAdapter(cmd)
                    mBo_doc_ghi_MySql.Fill(Me)
                Catch ex As MySqlException
                    ConnectionThanhcong = False
                    If batloi = True Then MsgBox("Không thực hiện dc!" & vbNewLine & ex.Message, vbCritical, "Lổi thực hiện")
                    Exit Sub
                End Try
        End Select
        Ngatketnoi()
    End Sub
#End Region
#Region "Khai báo phương thức xử lý - Nhóm cập nhật thông tin"
    Public Function Ghi_du_lieu() As Boolean
        Dim ketqua As Boolean = True
        Try
            mBo_doc_ghi_Access.Update(Me)
            Me.AcceptChanges()
        Catch ex As Exception
            Me.RejectChanges()
            ketqua = False
        End Try
        Return ketqua
    End Function
    Public Sub Loc_du_lieu(ByVal Bieu_thuc_loc As String)
        Try
            Me.DefaultView.RowFilter = Bieu_thuc_loc
        Catch ex As Exception
            If BatLoi = True Then MsgBox("Khong thuc hien dc!" & vbNewLine & ex.Message, vbCritical, "Loi thuc hien")
        End Try
    End Sub
#End Region
#Region "Khai báo các phương thức thực hiện lệnh"
    Public Function Thuc_hien_lenh(ByVal Lenh As String) As Integer
        Try
            Moketnoi()
            Select Case ketnoi.MSsql
                Case Class_KieuDL.Access
                    Dim Cau_lenh As New OleDbCommand(Lenh, mKet_noi_Access)
                    Dim ket_qua As Integer = Cau_lenh.ExecuteNonQuery()
                    Return ket_qua
                Case Class_KieuDL.Sql
                    Dim Cau_lenh As New SqlCommand(Lenh, mKet_noi_Sql)
                    Dim ket_qua As Integer = Cau_lenh.ExecuteNonQuery()
                    Return ket_qua
                Case Class_KieuDL.sqlExpress
                    Dim Cau_lenh As New SqlCommand(Lenh, mKet_noi_sqlExpress)
                    Dim ket_qua As Integer = Cau_lenh.ExecuteNonQuery()
                    Return ket_qua
                Case Class_KieuDL.SqlCe
                    Dim Cau_lenh As New SqlCeCommand(Lenh, mKet_noi_SqlCe)
                    Dim ket_qua As Integer = Cau_lenh.ExecuteNonQuery()
                    Return ket_qua
                Case Class_KieuDL.Oracle
                    Dim Cau_lenh As New OracleCommand(Lenh, mKet_noi_Oracle)
                    Dim ket_qua As Integer = Cau_lenh.ExecuteNonQuery()
                    Return ket_qua
                Case Class_KieuDL.MySql
                    Dim Cau_lenh As New MySqlCommand(Lenh, mKet_noi_MySql)
                    Dim ket_qua As Integer = Cau_lenh.ExecuteNonQuery()
                    Return ket_qua
            End Select
        Catch ex As OleDbException
            If BatLoi = True Then MsgBox("Khong thuc hien dc!" & vbNewLine & ex.Message, vbCritical, "Loi thuc hien")
            Return -1
        End Try
        Ngatketnoi()
    End Function
    Public Function Thuc_hien_lenh_tinh_toan(ByVal Lenh As String) As Object
        Try
            Moketnoi()
            Select Case ketnoi.MSsql
                Case Class_KieuDL.Access
                    Dim Cau_lenh As New OleDbCommand(Lenh, mKet_noi_Access)
                    Dim ket_qua As Object = Cau_lenh.ExecuteScalar
                    Return ket_qua
                Case Class_KieuDL.Sql
                    Dim Cau_lenh As New SqlCommand(Lenh, mKet_noi_Sql)
                    Dim ket_qua As Object = Cau_lenh.ExecuteScalar
                    Return ket_qua
                Case Class_KieuDL.sqlExpress
                    Dim Cau_lenh As New SqlCommand(Lenh, mKet_noi_sqlExpress)
                    Dim ket_qua As Object = Cau_lenh.ExecuteScalar
                    Return ket_qua
                Case Class_KieuDL.SqlCe
                    Dim Cau_lenh As New SqlCeCommand(Lenh, mKet_noi_SqlCe)
                    Dim ket_qua As Object = Cau_lenh.ExecuteScalar
                    Return ket_qua
                Case Class_KieuDL.Oracle
                    Dim Cau_lenh As New OracleCommand(Lenh, mKet_noi_Oracle)
                    Dim ket_qua As Object = Cau_lenh.ExecuteScalar
                    Return ket_qua
                Case Class_KieuDL.MySql
                    Dim Cau_lenh As New MySqlCommand(Lenh, mKet_noi_MySql)
                    Dim ket_qua As Object = Cau_lenh.ExecuteScalar
                    Return ket_qua
            End Select
        Catch ex As OleDbException
            If BatLoi = True Then MsgBox("Khong thuc hien dc!" & vbNewLine & ex.Message, vbCritical, "Loi thuc hien")
            Return -1
        End Try
        Ngatketnoi()
    End Function
#End Region
#Region "Xử lý sự kiện"
    Private Sub mBo_doc_ghi_RowUpdated(ByVal sender As Object, ByVal e As _
         System.Data.OleDb.OleDbRowUpdatedEventArgs) Handles mBo_doc_ghi_access.RowUpdated
        If Me.PrimaryKey(0).AutoIncrement Then
            If e.Status = UpdateStatus.[Continue] And e.StatementType = StatementType.Insert Then
                Dim cmd As New OleDbCommand("Select @@IDENTITY", mKet_noi_Access)
                e.Row.Item(0) = cmd.ExecuteScalar
                Me.AcceptChanges()
            End If
        End If
    End Sub
#End Region
End Class

